package com.example.takeaway.serivce.impl;

import java.util.List;

import com.example.takeaway.entity.Goods;
import com.example.takeaway.entity.User;
import com.example.takeaway.entity.VO.LoginUser;
import com.example.takeaway.mapper.UserMapper;
import com.example.takeaway.serivce.IUserService;
import com.example.takeaway.utils.PageResult;
import com.example.takeaway.utils.PageUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * userService业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-16
 */
@Service
public class UserServiceImpl implements IUserService
{
    @Autowired
    private UserMapper userMapper;

    @Override
    public User getuser(LoginUser loginUser) {
        return userMapper.getuser(loginUser);
    }

    @Override
    public User getuserById(Integer userId) {
        return userMapper.getuserById(userId);
    }

    /**
     * 查询user
     * 
     * @param userid user主键
     * @return user
     */
    @Override
    public User selectUserByUserid(Long userid)
    {
        return userMapper.selectUserByUserid(userid);
    }

    /**
     * 查询user列表
     * 
     * @param user user
     * @return user
     */
    @Override
    public PageResult selectUserList(User user ,int pageNum, int pageSize)
    {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = userMapper.selectUserList(user);
        PageInfo<User> pageInfo = new PageInfo<>(list);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return pageResult;
    }

    /**
     * 新增user
     * 
     * @param user user
     * @return 结果
     */
    @Override
    public int insertUser(User user)
    {
        return userMapper.insertUser(user);
    }

    /**
     * 修改user
     * 
     * @param user user
     * @return 结果
     */
    @Override
    public int updateUser(User user)
    {
        return userMapper.updateUser(user);
    }

    /**
     * 批量删除user
     * 
     * @param userids 需要删除的user主键
     * @return 结果
     */
    @Override
    public int deleteUserByUserids(Long[] userids)
    {
        return userMapper.deleteUserByUserids(userids);
    }

    /**
     * 删除user信息
     * 
     * @param userid user主键
     * @return 结果
     */
    @Override
    public int deleteUserByUserid(Long userid)
    {
        return userMapper.deleteUserByUserid(userid);
    }
}
